package br.com.lavitstudio.game;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;

import javax.imageio.ImageIO;

public class Tile {
	public static int tileSize = 20;
	public static int invLength = 8;
	public static int invHeight = 4;
	public static int invCellSize = 25;
	public static int invCellSpace = 4;
	public static int invBorderSpace = 4;
	public static int invItemBorder = 3;
	public static int maxMobs = 10;
	public static int maxMobsAnimals = 8;

	// Terreno (adicionar tambem o terreno em getTile)
	public static final HashMap<String, int[]> block = new HashMap<String, int[]>();
	
	private final int[] block_null	= {-1, -1, 999};	// Air
	private final int[] block_0_1	= { 0,  1, 999};	// SolidAir
	private final int[] block_0_0	= { 0,  0, 100};	// Earth
	private final int[] block_1_0	= { 1,  0, 100};	// Grass
	private final int[] block_2_0	= { 2,  0, 50};		// Sand
	private final int[] block_3_0	= { 3,  0, 25};		// Glass
	private final int[] block_4_0	= { 4,  0, 999};	// BadRock
	private final int[] block_5_0	= { 5,  0, 125};	// Wood
	private final int[] block_6_0	= { 6,  0, 50};		// Leaves
	private final int[] block_7_0	= { 7,  0, 999};	// Cave
	private final int[] block_8_0 	= { 8,  0, 100};	// CaveGrass
	private final int[] block_9_0	= { 9,  0, 75};		// SandBlock
	private final int[] block_10_0	= { 10, 0, 200};	// Rocha
	
	// Sol
	public static final int[] moon		 = {0, 0};
	
	// Lua
	public static final int[] sun		 = {0, 0};
	
	// Personagem
	public static final int[] mob_player_Walking	= {0, 0};   // Caminhando
	public static final int[] mob_player_Running	= {0, 2};   // Correndo
	public static final int[] mob_player_Resting	= {0, 4};   // Descansando
	public static final int[] mob_player_Sitting	= {0, 6};   // Sentado
	public static final int[] mob_player_Working	= {0, 8};   // Trabalhando
	public static final int[] mob_player_Jump		= {0, 10};  // Pulando
	public static final int[] mob_player_Atack1		= {0, 12};  // Ataque Soco
	public static final int[] mob_player_Atack2		= {0, 14};  // Ataque Chute
	public static final int[] mob_player_Atack3		= {0, 16};  // Ataque Arco
	public static final int[] mob_player_Atack4		= {0, 18};  // Ataque Magia
	public static final int[] mob_player_Atack5		= {0, 20};  // Ataque Espada 1
	public static final int[] mob_player_Atack6		= {0, 22};  // Ataque Espada 2
	public static final int[] mob_player_Atack7		= {0, 24};  // Ataque Tiro
	
	// Mosntros
	public static final int[] mob_ORC001		= {0, 0};
	public static final int[] mob_ORC002		= {0, 2};
	public static final int[] mob_ORC003		= {0, 4};
	
	// Animais
	public static final int[] mob_Animal001		= {0, 1};
	public static final int[] mob_Animal002		= {0, 3};
	
	// Tools
	private final int[] tools_0_0	= {0, 0};
	private final int[] tools_0_1	= {0, 1};
	private final int[] tools_0_2	= {0, 2};
	
	public static final HashMap<String, int[]> tools = new HashMap<String, int[]>();
	
	// Weapons
	
	// Itens
	
	// Armor
	
	public static BufferedImage desktop;
	
	public static BufferedImage tile_terrain;
	public static BufferedImage tile_cell;
	public static BufferedImage tile_select;
	public static BufferedImage tile_char;
	public static BufferedImage tile_mob;
	public static BufferedImage tile_mobAnimal;
	public static BufferedImage tile_tools;
	public static BufferedImage tile_weapons;
	public static BufferedImage tile_itens;
	public static BufferedImage tile_armor;
	public static BufferedImage tile_sun;
	public static BufferedImage tile_moon;
	public static BufferedImage tile_break;
	public static BufferedImage tile_info;
	
	public Tile() {
		try {
			Tile.desktop = ImageIO.read(new File("res/desktop.png"));
			Tile.tile_terrain = ImageIO.read(new File("res/tile_terrain.png"));
			Tile.tile_cell = ImageIO.read(new File("res/tile_cell.png"));
			Tile.tile_select = ImageIO.read(new File("res/tile_select.png"));
			Tile.tile_char = ImageIO.read(new File("res/tile_char.png"));
			Tile.tile_mob = ImageIO.read(new File("res/tile_mob.png"));
			Tile.tile_mobAnimal = ImageIO.read(new File("res/tile_mobAnimal.png"));
			Tile.tile_tools = ImageIO.read(new File("res/tile_tools.png"));
			Tile.tile_weapons = ImageIO.read(new File("res/tile_weapons.png"));
			Tile.tile_itens = ImageIO.read(new File("res/tile_itens.png"));
			Tile.tile_armor = ImageIO.read(new File("res/tile_armor.png"));
			Tile.tile_sun = ImageIO.read(new File("res/tile_sun.png"));
			Tile.tile_moon = ImageIO.read(new File("res/tile_moon.png"));
			Tile.tile_break = ImageIO.read(new File("res/tile_break.png"));
			Tile.tile_info = ImageIO.read(new File("res/tile_info.png"));
		} catch(Exception e) { }
		
		block.put("air",		block_null);
		block.put("solidair",	block_0_1);
		block.put("earth",		block_0_0);
		block.put("grass",		block_1_0);
		block.put("sand",		block_2_0);
		block.put("glass",		block_3_0);
		block.put("badrock",	block_4_0);
		block.put("wood",		block_5_0);
		block.put("leaves",		block_6_0);
		block.put("cave",		block_7_0);
		block.put("caveGrass",	block_8_0);
		block.put("sandBlock",	block_9_0);
		block.put("rock",		block_10_0);
		
		tools.put("pickaxe",	tools_0_0);
		tools.put("axe",		tools_0_1);
		tools.put("shovel",		tools_0_2);
		
	}
	
	public static int[] getTile(int x, int y) {
		int[] id = block.get("air");
		
		if(x == -1 && y == -1) id = block.get("air");
		if(x == 0  && y == 1 ) id = block.get("solidair");
		if(x == 0  && y == 0 ) id = block.get("earth");
		if(x == 1  && y == 0 ) id = block.get("grass");
		if(x == 2  && y == 0 ) id = block.get("sand");
		if(x == 3  && y == 0 ) id = block.get("glass");
		if(x == 4  && y == 0 ) id = block.get("badrock");
		if(x == 5  && y == 0 ) id = block.get("wood");
		if(x == 6  && y == 0 ) id = block.get("leaves");
		if(x == 7  && y == 0 ) id = block.get("cave");
		if(x == 8  && y == 0 ) id = block.get("caveGrass");
		if(x == 9  && y == 0 ) id = block.get("sandBlock");
		if(x == 10 && y == 0 ) id = block.get("rock");
		
		return id;
	}
}
